﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wise.TimeWarrior.DTO;
using Wise.TimeWarrior.Impl;
using Wise.TimeWarrior.Interfaces;

namespace TimeWarrior.Test
{
    [TestClass]
    public class ConfigurationTest
    {
        [TestMethod]
        public void SaveAndReadTestConfig()
        {
            IConfiguration conf = new ConfigurationService();

            ConfigurationDto confDto = conf.ReadConfiguration();
            confDto.MinutesOfWorkingHouersPerDay = 8 * 60;
            confDto.MinutesOfFreeTimePerDay = 15;
            confDto.WorkingHoursStartWatchTime = "8:00";
            confDto.WorkingHoursEndWatchTime = "16:00";
            conf.SaveConfiguration(confDto);


            ConfigurationDto afterInit = conf.ReadConfiguration();
            Assert.AreEqual(confDto.MinutesOfWorkingHouersPerDay, afterInit.MinutesOfWorkingHouersPerDay);
            Assert.AreEqual(confDto.MinutesOfFreeTimePerDay, afterInit.MinutesOfFreeTimePerDay);
            Assert.AreEqual(confDto.WorkingHoursStartWatchTime, afterInit.WorkingHoursStartWatchTime);
            Assert.AreEqual(confDto.WorkingHoursEndWatchTime, afterInit.WorkingHoursEndWatchTime);


            afterInit.MinutesOfWorkingHouersPerDay = 8 * 60;
            afterInit.MinutesOfFreeTimePerDay = 30;
            afterInit.WorkingHoursStartWatchTime = "8:00";
            afterInit.WorkingHoursEndWatchTime = "18:00";

            conf.SaveConfiguration(afterInit);


            ConfigurationDto afterUpdate = conf.ReadConfiguration();
            Assert.AreEqual(afterInit.MinutesOfWorkingHouersPerDay, afterUpdate.MinutesOfWorkingHouersPerDay);
            Assert.AreEqual(afterInit.MinutesOfFreeTimePerDay, afterUpdate.MinutesOfFreeTimePerDay);
            Assert.AreEqual(afterInit.WorkingHoursStartWatchTime, afterUpdate.WorkingHoursStartWatchTime);
            Assert.AreEqual(afterInit.WorkingHoursEndWatchTime, afterUpdate.WorkingHoursEndWatchTime);


        }
    }
}
